/*  ResultGui.Java
 * 
 *  WebCrawler Program
 *  @author Amandeep Jhajj and Craig Markham
 *  @date 26Apr2012
 */

package GUI;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
/**
 * the results gui
 *
 */
public class ResultGui {

	private JFrame my_frame = new JFrame("Results");
	JScrollPane myScrollPane;

	JTextArea  myTextPane = new JTextArea ();
	Font theFont;
	private String theResult;
	public ResultGui() {
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * the setup panel for the GUI
	 * the frame just has one compent with scrollables
	 */
	public void start(){
		myScrollPane = new JScrollPane(myTextPane);
		my_frame.setLayout(new GridLayout(1, 1));
		myScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		my_frame.add(myScrollPane);
		my_frame.setSize(700, 700);
		my_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		my_frame.setVisible(true);
	}
	
	/**
	 * posts the results on our gui
	 * @param my_results_string
	 */
	public void update(String my_results_string) {
		theResult = my_results_string;
		myTextPane.append(theResult);
		theFont = new Font("Courier", Font.PLAIN, 14);
		myTextPane.setFont(theFont);
		myTextPane.setCaretPosition( myTextPane.getDocument().getLength() );		
	}
}
